package cn.fan.rabbitMQ.listener;

import cn.fan.service.RaskremindService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class RemindListener {
    @Autowired
    private RaskremindService raskremindService;

    @RabbitListener(queues = "error.queue")
    public void error(String msg){
        log.error("死信队列"+msg);
    }

    @RabbitListener(queues = "remind.queue")
    public void taskRemind(long id){
        log.info("提醒任务开始");

        Thread t1= new Thread(){
            public void run(){
                raskremindService.isRemind();
                log.info("提醒任务："+id+"已完成!");
            }
        };
        t1.start();

    }
}
